package demo1;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class Test {
    public static void main(String[] args) {
        //test1();
        test2();
    }

    public static void test1() {
        Deque<Integer> deque = new ArrayDeque<>();
        deque.offerFirst(1);
        deque.offerFirst(10);
        deque.offerFirst(100);
        deque.offerFirst(1000);
        deque.offerLast(2);
        deque.offerLast(20);
        System.out.println(deque);
        deque.pollFirst();//出队列的头元素：1000
        System.out.println(deque);
        deque.pollLast();//出队列的尾元素：20
        System.out.println(deque);
        System.out.println(deque.peekFirst());
        System.out.println(deque.peekLast());
        System.out.println(deque);
    }
    public static void test2() {
        Deque<Integer> deque = new LinkedList<>();
        deque.offerFirst(1);
        deque.offerFirst(10);
        deque.offerFirst(100);
        deque.offerFirst(1000);
        deque.offerLast(2);
        deque.offerLast(20);
        System.out.println(deque);
        deque.pollFirst();//出队列的头元素：1000
        System.out.println(deque);
        deque.pollLast();//出队列的尾元素：20
        System.out.println(deque);
        System.out.println(deque.peekFirst());
        System.out.println(deque.peekLast());
        System.out.println(deque);
    }
}